from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from django.views.decorators.cache import never_cache
from django.shortcuts import render_to_response

# import the logging library
import logging

# Get an instance of a logger
logger = logging.getLogger(__name__)

def index(request):
    logger.info('in views.py')
    return HttpResponseRedirect(reverse("registration_register"))
    
@login_required
@never_cache
def profile_list(request):
	#page = strings.list
	sub_template = 'profile_list.html'
	#from ad.all import getUserAds
	#ads = getUserAds(request.user)
	return render_to_response("profile.html", locals())	
    
@login_required
@never_cache
def profile_edit(request):
	#page = strings.edit
	view = "edit"
	sub_template = 'profile_edit.html'
	from profile import ProfileForm, getAsDic
	if request.method == 'POST': 		
		form = ProfileForm(request.POST)
		if form.is_valid():
			form.save(request.user)
			message = strings.dataWasSaved
	else:				
		form = ProfileForm(getAsDic(request.user))
			 
	return render_to_response("profile.html", locals())